/*
//              INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license  agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in  accordance  with the terms of that agreement.
//    Copyright (c) 2003-2007 Intel Corporation. All Rights Reserved.
//
//
*/
#include "umc_defs.h"
#if defined (UMC_ENABLE_DV_VIDEO_DECODER)

#ifndef __UMC_DV_SEQUENCE_H
#define __UMC_DV_SEQUENCE_H

namespace UMC
{

enum
{
    WIDTH_ALIGN                 = 128,
    MEMORY_ALIGN                = 128,
    WIDTH_DV                    = 720,
    HEIGHT_625                  = 576,
    HEIGHT_525                  = 480,

    SIZE_OF_VIDEO_SEGMENT       = sizeof(Ipp16u) * 64 * 6 * 5,
    SIZE_OF_DV_SEGMENT          = 80
};

enum
{
    SYSTEM_UNK                  = 0,
    SYSTEM_525                  = 1,
    SYSTEM_625                  = 2
};

enum
{
    NONE_STREAM                 = 0,
    DVSD_STREAM                 = 1,
    DV25_STREAM                 = 2,
    DV50_STREAM                 = 3
};

class STORE_DV_SEGMENT_INFO
{
public:
    size_t m_lPitch;                                        // (size_t) image pitch
    ColorFormat m_cFormat;                                    // (ColorFormat) color format of destination image

    Ipp16u *(m_lpsSource[5]);                                 // (Ipp16u *([])) array of source pointers
    Ipp8u *(m_lpbDestination[5]);                             // (Ipp8u *([])) array of destination pointers

};
typedef STORE_DV_SEGMENT_INFO LOAD_DV_SEGMENT_INFO;

class THREAD_ID
{
public:
    Ipp32u m_nNumber;                                         // (Ipp32u) number of current thread
    void *m_lpOwner;                                          // (void *) pointer to owner class
};

#pragma pack(1)

enum SectionType
{
    Video                       = -4,
    Reserved0                   = -3,
    Reserved1                   = -2,
    Reserved2                   = -1,
    Header                      = 0,
    Subcode                     = 1,
    VAUX                        = 2,
    Audio                       = 3
};

// following tables hold information of encoded DV stream
// See "Blue book" for details
class IDData
{
public:
    Ipp32u Seq      : 4;
    Ipp32u          : 1;
    SectionType SCT : 3;

    Ipp32u          : 3;
    Ipp32u zero     : 1;
    Ipp32u Dseq     : 4;

    Ipp32u DBN      : 8;

    Ipp32u          : 8;
};

class DIFBlock
{
public:
    IDData *GetIDData(void)
    {
        return ((IDData *) (DIFBlockData));
    };

    Ipp8u DIFBlockData[80];
};

class HeaderData
{
public:
    Ipp32u       : 6;
    Ipp32u zero  : 1;
    Ipp32u DSF   : 1;

    Ipp32u APT   : 3;
    Ipp32u       : 1;
    Ipp32u DFTIA : 4;

    Ipp32u AP1   : 3;
    Ipp32u       : 4;
    Ipp32u TF1   : 1;

    Ipp32u AP2   : 3;
    Ipp32u       : 4;
    Ipp32u TF2   : 1;

    Ipp32u AP3   : 3;
    Ipp32u       : 4;
    Ipp32u TF3   : 1;

    Ipp32u       : 24;
};

// some compilers complain to "non-virtual destructor for base class".
// But following classes are structures of data from media file.
// They MUST HAVE no destructor.
#pragma warning (disable : 444)

class HeaderSection : public DIFBlock
{
public:
    HeaderData *GetHeaderData(void)
    {
        return ((HeaderData *) (DIFBlockData + 3));
    };
};

class SubCodeSection : public DIFBlock
{
public:
};

class VAUXSection : public DIFBlock
{
public:
};

class AudioSection : public DIFBlock
{
public:
};

class VideoSection : public DIFBlock
{
public:
};

class AudioVideoSection
{
public:
    AudioSection A;
    VideoSection V[15];
};

class DIFSequence
{
public:
    HeaderSection H0;
    SubCodeSection SC0;
    SubCodeSection SC1;
    VAUXSection VA0;
    VAUXSection VA1;
    VAUXSection VA2;
    AudioVideoSection AV[9];
};

} // end namespace UMC

#endif // __UMC_DV_SEQUENCE_H

#endif //(UMC_ENABLE_DV_VIDEO_DECODER)
